/*
 * @Author: your name
 * @Date: 2022-03-21 16:05:15
 * @LastEditTime: 2022-04-10 14:30:13
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \22-03-19 智慧社区\behaviors\comm.js
 */
let { statusBarHeight, titleBarHeight, canUse } = getApp().globalData
export default Behavior({
  behaviors: [],
  properties: {
    myBehaviorProperty: {
      type: String,
    },
  },
  data: {
    navBarHeight: statusBarHeight + titleBarHeight,
    canUse,
    nvabarData: {
      navigationBarTextStyle: 'black', // 胶囊主题 white || black
      navigationBarTitleText: '', //  导航栏标题文本
      navigationBarBackground: '#fff', // 导航栏背景色
      fixed: false, // 开启定位
      // statusBgColor: '', // 状态栏背景色
      // showPre: true, // 是否只展示返回键 默认 false
      // hideCapsule: true, // 是否隐藏胶囊
    },
  },
  attached: function () {
    // 配置页面导航栏
    const curPages = getCurrentPages().slice(getCurrentPages().length - 1)[0]
    const { window: pageWindow } = __wxConfig.page[`${curPages.route}.html`]
    // const { pageOrientation } = pageWindow
    // const rootFontSize = `2.6667${pageOrientation === 'landscape' ? 'vh' : 'vw'}`; // 横屏则根据屏幕高度
    let { nvabarData } = this.data
    for (let [key, val] of Object.entries(nvabarData)) {
      nvabarData[key] = val || pageWindow[key]
    }
    this.setData({ nvabarData })
  },
  methods: {
    goback() {
      wx.navigateBack({
        delta: 1,
      })
    },
  },
})
